package Models.dao;

import Models.enity.Type;
import Models.utils.DataSourceManager;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import java.sql.SQLException;
import java.util.List;

public class TypeDao {
    private QueryRunner runner = new QueryRunner(DataSourceManager.getDataSource());

    public List<Type> findAll(){
        String sql = "SELECT * FROM type";
        try {
            return runner.query(sql,new BeanListHandler<Type>(Type.class));
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return null;
    }
}
